package com.apes.scm.masterdata.product.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @program: apes-server
 * @description:
 * @author: czs
 * @create: 2023-02-03 15:24
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ProductNegativeSelling.CONST_TABLE_NAME)
public class ProductNegativeSelling extends Model {
    public static final String CONST_TABLE_NAME = "mas_product_negative_selling";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "商品编码", padding = 10)
    @Comment("负卖商品编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "product_id", referencedColumnName = "id")
    @Comment("商品")
    private Product product;

    @Transient
    private Brand brand;

    public Brand getBrand() {
        return product.getBrand();
    }

    @Transient
    private Category category;

    public Category getCategory() {
        return product.getCategory();
    }

    @Transient
    private String state;

    public String getState() {
        return product.getState();
    }

    @Column(name = "valid")
    @Comment("有效标记")
    private boolean valid = true; //有效

}
